home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / reader_requests / wild / support / wabl / dxf2wabl / dxf2wabl.c.old < prev    next >
Text File  |  2000-02-23  |  17KB  |  576 lines

  1. /*
  2. **    Dxf2WABL: Converts a DXF (with 3DFace statements) into a WABL file.
  3. **          Multiple colors give multiple sectors of the same alien.
  4. **          No relative origin calc: do it in editWABLAlien.
  5. */
  6.  
  7. #include <wabl.h>
  8. #include <exec/exec.h>
  9. #include <exec/libraries.h>
  10. #include <dos/dos.h>
  11. #include <utility/tagitem.h>
  12. #include <utility/hooks.h>
  13. #include <inline/dos.h>
  14. #include <inline/exec.h>
  15. #include <exec/lists.h>
  16.  
  17. extern struct ExecBase *SysBase;
  18. extern struct Library *DOSBase;
  19.  
  20. #define ARG_DXFINPUT    0
  21. #define    ARG_WABLOUTPUT    1
  22. #define    ARG_NOCOLORS    2
  23. #define ARG_QUIET    3
  24. #define ARG_VERBOSE    4
  25.  
  26. #define DOING_WAITFACE    50
  27. #define DOING_FNDFACE    51
  28. #define    DOING_VALUEXA    0
  29. #define    DOING_VALUEXB    1
  30. #define    DOING_VALUEXC    2
  31. #define    DOING_VALUEXD    3
  32. #define    DOING_VALUEYA    4
  33. #define    DOING_VALUEYB    5
  34. #define    DOING_VALUEYC    6
  35. #define    DOING_VALUEYD    7
  36. #define    DOING_VALUEZA    8
  37. #define    DOING_VALUEZB    9
  38. #define    DOING_VALUEZC    10
  39. #define    DOING_VALUEZD    11
  40. #define DOING_VALUECOLOR 12
  41. #define DOING_VALUENULL    99
  42.  
  43. struct DXFGlobal
  44. {
  45.  struct MinList dxg_objs;
  46. };
  47.  
  48. struct DXFObj
  49. {
  50.  struct MinNode    dxo_node;
  51.  struct MinList    dxo_faces;
  52.  struct MinList dxo_ifaces;
  53.  struct MinList dxo_iedges;
  54.  struct MinList dxo_points;
  55.  UWORD        dxo_color;
  56. };
  57.  
  58. struct DXFFace
  59. {
  60.  struct MinNode    dxf_node;
  61.  struct DXFPoint *dxf_pa;
  62.  struct DXFPoint *dxf_pb;
  63.  struct DXFPoint *dxf_pc;
  64.  struct DXFPoint *dxf_pd;
  65.  UWORD        dxf_id;
  66.  UWORD        dxf_color;
  67. };
  68.  
  69. struct INTERFace
  70. {
  71.  struct MinNode    if_node;
  72.  struct DXFPoint *if_pa;
  73.  struct DXFPoint *if_pb;
  74.  struct DXFPoint *if_pc;
  75.  UWORD        if_id; 
  76. };
  77.  
  78. struct INTEREdge
  79. {
  80.  struct MinNode ie_node;
  81.  struct DXFPoint *ie_pa;
  82.  struct DXFPoint *ie_pb; 
  83.  UWORD        ie_id;
  84. };
  85.  
  86. struct DXFPoint
  87. {
  88.  struct MinNode dxp_node;
  89.  int        dxp_x;
  90.  int        dxp_y;
  91.  int        dxp_z;
  92.  struct DXFPoint *dxp_remap;
  93.  UWORD        dxp_id;
  94. };
  95.  
  96. static const char Intro[]={"\nDxf2Wabl 1.5\n\0"};
  97. static const char Loading[]={"\nLoadind DXF file.\0"};
  98. static const char NewObj[]={"\nFound new object (color).\0"};
  99. static const char Converting[]={"\nConverting formats.\0"};
  100. static const char DoublePnts[]={"\nPacking double points.\0"};
  101. static const char CreatePnts[]={"\nCreating points.\0"};
  102. static const char DoubleFaces[]={"\nPacking and splitting faces (4 edges to 3).\0"};
  103. static const char CreateFaces[]={"\nCreating faces and packing edges.\0"};
  104. static const char AddEdges[]={"\nCreating edges.\0"};
  105. static const char Saving[]={"\nSaving WABL file.\0"};
  106. static const char Bye[]={"\nEnjoy WILD using !!\n\n\0"};
  107. static const char FndFace[]={"\nFac \0"};
  108. static const char RemapPoint[]={"\nRemap point : xxxx into xxxx \0"};
  109. #define    RMP_IT    15
  110. #define RMP_INTO 25
  111. static const char OriginalFace[]={"\nOriginal DXF face points : xxxx xxxx xxxx xxxx \0"};
  112. #define ORF_PA 28
  113. #define ORF_PB 33
  114. #define ORF_PC 38
  115. #define ORF_PD 43
  116. static const char TDFACE[]={"3DFACE\n\0"};
  117. static const char FndXA[]={"XA:\0"};
  118. static const char FndXB[]={"XB:\0"};
  119. static const char FndXC[]={"XC:\0"};
  120. static const char FndXD[]={"XD:\0"};
  121. static const char FndYA[]={"YA:\0"};
  122. static const char FndYB[]={"YB:\0"};
  123. static const char FndYC[]={"YC:\0"};
  124. static const char FndYD[]={"YD:\0"};
  125. static const char FndZA[]={"ZA:\0"};
  126. static const char FndZB[]={"ZB:\0"};
  127. static const char FndZC[]={"ZC:\0"};
  128. static const char FndZD[]={"ZD:\0"};
  129. static const char FndCL[]={"C:\0"};
  130. static const char NumFmt[]={'%','l','d',9,0};
  131. static const char AlienType[]={"Alien\0"};
  132. static const char AlienName[]={"Unnamed\0"};
  133. static const char SectorType[]={"Sector\0"};
  134.              char SectorName[7]={'S','e','c','X','X','X',0};
  135. static const char ShellType[]={"Shell\0"};
  136.              char ShellName[7]={'S','h','e','X','X','X',0};
  137. static const char WireType[]={"Wire\0"};
  138.              char WireName[7]={'W','i','r','X','X','X',0};
  139. static const char NebulaType[]={"Nebula\0"};
  140.              char NebulaName[7]={'N','e','b','X','X','X',0};
  141. static const char FaceType[]={"Face\0"};
  142.              char FaceName[8]={'F','a','c','X','X','X','X',0};
  143. static const char EdgeType[]={"Edge\0"};
  144.              char EdgeName[8]={'E','d','g','X','X','X','X',0};
  145. static const char PointType[]={"Point\0"};
  146.              char PointName[8]={'D','o','t','X','X','X','X',0};
  147. static const char PointX[]={"X\0"};
  148. static const char PointY[]={"Y\0"};
  149. static const char PointZ[]={"Z\0"};
  150. static const char FacePA[]={"PA\0"};
  151. static const char FacePB[]={"PB\0"};
  152. static const char FacePC[]={"PC\0"};
  153. static const char FaceEA[]={"EA\0"};
  154. static const char FaceEB[]={"EB\0"};
  155. static const char FaceEC[]={"EC\0"};
  156. #define EdgePA FacePA
  157. #define EdgePB FacePB
  158.  
  159. ULONG     *outfh=NULL,arg[6];
  160. struct WABL *wabl=NULL;
  161.  
  162. ULONG WriteHook( register struct Hook* hook __asm("a0"), register ULONG object __asm("a2"), register ULONG message __asm("a1"))
  163. {
  164.  return(FPutC(object,message));
  165. }
  166.  
  167. ULONG RawDoFmtOut( register ULONG car __asm("d0"), register ULONG output __asm("a3") )
  168. {
  169.  FPutC(output,car);
  170. }
  171.  
  172. struct DXFObj *HaveObjFromColor(struct DXFGlobal *dxf,UWORD col)
  173. {
  174.  struct DXFObj *cob,*nob;
  175.  cob=dxf->dxg_objs.mlh_Head;
  176.  while (nob=cob->dxo_node.mln_Succ)
  177.   {
  178.    if (cob->dxo_color==col) return(cob);
  179.    cob=nob;
  180.   }
  181.  cob=AllocPooled(wabl->WABL_Pool,sizeof(struct DXFObj));
  182.  cob->dxo_color=col;
  183.  Say(NewObj);
  184.  NewList(cob->dxo_faces);
  185.  NewList(cob->dxo_ifaces);
  186.  NewList(cob->dxo_iedges);
  187.  NewList(cob->dxo_points);
  188.  AddTail(&dxf->dxg_objs,&cob->dxo_node);
  189. }
  190.  
  191. void Val(int num,char *str)
  192. {
  193.  int a;
  194.  if ((a=LongToStr(num,str,-1))>0)
  195.   {
  196.    str[a]=0;
  197.   }
  198.  else
  199.   {
  200.    str[0]=0;
  201.   }
  202. }
  203.  
  204. ULONG *HaveRemapPoint(struct DXFPoint *pnt)
  205. {
  206.  if (pnt->dxp_remap)
  207.   {
  208.    return(HaveRemapPoint(pnt->dxp_remap));
  209.   }
  210.  else
  211.   {
  212.    return(pnt);
  213.   }
  214. }
  215.  
  216. ULONG *AddINTERFace(struct DXFObj *obj,struct DXFPoint *pa,struct DXFPoint *pb,struct DXFPoint *pc)
  217. {
  218.  if ((pa==pb) | (pa==pc) | (pb==pc)) return(0L);
  219.  {
  220.   struct INTERFace *cif,*nif;
  221.   cif=obj->dxo_ifaces.mlh_Head;
  222.   while (nif=cif->if_node.mln_Succ)
  223.    {
  224.     if (((cif->if_pa==pa) & (cif->if_pb==pb) & (cif->if_pc==pc))|
  225.         ((cif->if_pa==pa) & (cif->if_pb==pc) & (cif->if_pc==pb))|
  226.         ((cif->if_pa==pb) & (cif->if_pb==pa) & (cif->if_pc==pc))|
  227.         ((cif->if_pa==pb) & (cif->if_pb==pc) & (cif->if_pc==pa))|
  228.         ((cif->if_pa==pc) & (cif->if_pb==pa) & (cif->if_pc==pb))|
  229.         ((cif->if_pa==pc) & (cif->if_pb==pb) & (cif->if_pc==pa))) return(0L);
  230.     cif=nif;
  231.    }
  232.   cif=AllocPooled(wabl->WABL_Pool,sizeof(struct INTERFace));
  233.   cif->if_pa=pa;
  234.   cif->if_pb=pb;
  235.   cif->if_pc=pc;
  236.   AddTail(&obj->dxo_ifaces,&cif->if_node);
  237.   return (cif);
  238.  }
  239. }
  240.  
  241. ULONG *AddINTEREdge(struct DXFObj *obj,struct DXFPoint *pa,struct DXFPoint *pb)
  242. {
  243.  struct INTEREdge *cie,*nie;
  244.  if (pa==pb) return(0L);
  245.  cie=obj->dxo_iedges.mlh_Head;
  246.  while (nie=cie->ie_node.mln_Succ)
  247.   {
  248.    if (((cie->ie_pa==pa) & (cie->ie_pb==pb))|
  249.        ((cie->ie_pa==pb) & (cie->ie_pb==pa))) return(cie);
  250.    cie=nie;
  251.   }
  252.  cie=AllocPooled(wabl->WABL_Pool,sizeof(struct INTEREdge));
  253.  cie->ie_pa=pa;
  254.  cie->ie_pb=pb;
  255.  cie->ie_id=NULL;
  256.  AddTail(&obj->dxo_iedges,&cie->ie_node);
  257.  return (cie);
  258. }
  259.  
  260. ULONG *AddDXFPoint(struct DXFObj *obj,int x,int y,int z)
  261. {
  262.  struct DXFPoint *cpo,*npo;
  263.  cpo=obj->dxo_points.mlh_Head;
  264.  while (npo=cpo->dxp_node.mln_Succ)
  265.   {
  266.    if ((cpo->dxp_x==x) & (cpo->dxp_y==y) & (cpo->dxp_z==z)) return(cpo);
  267.    cpo=npo;
  268.   }
  269.  cpo=AllocPooled(wabl->WABL_Pool,sizeof(struct DXFPoint));
  270.  cpo->dxp_x=x;
  271.  cpo->dxp_y=y;
  272.  cpo->dxp_z=z;
  273.  AddTail(&obj->dxo_points,&cpo->dxp_node);
  274.  return(cpo);
  275. }
  276.  
  277. void SayV(char *str)
  278. {
  279.  if (arg[ARG_VERBOSE])
  280.   {
  281.    FPuts(outfh,str);
  282.   }
  283. }
  284.  
  285. void Say(char *str)
  286. {
  287.  if (arg[ARG_QUIET]==0)
  288.   {
  289.    FPuts(outfh,str);
  290.   }
  291. }
  292.  
  293. int main()
  294. {
  295.  ULONG *rda;
  296.  outfh=Output();
  297.  Say(Intro);
  298.  if (rda=ReadArgs("DXFIN/A,WABLOUT/A,NOCOLORS/S,QUIET/S,VERBOSE/S",&arg,0))
  299.   {
  300.    ULONG *fh;
  301.    if (fh=Open(arg[ARG_DXFINPUT],MODE_OLDFILE))
  302.     {
  303.      struct Hook puthook;
  304.      if (wabl=NewWABL())
  305.       {
  306.        char *use;
  307.        struct DXFGlobal dxf;
  308.        struct DXFFace    *face;
  309.        struct DXFPoint    *pa,*pb,*pc,*pd;
  310.        NewList(dxf.dxg_objs);
  311.        Say(Loading);
  312.        if (use=AllocPooled(wabl->WABL_Pool,16384))
  313.         {
  314.          UBYTE doing=DOING_WAITFACE;
  315.          ULONG idface=NULL,idedge=NULL,idpoint=NULL;
  316.          while (FGets(fh,use,16384))
  317.           {
  318.        if (doing==DOING_WAITFACE)
  319.         {
  320.          if (StrCmp(use,&TDFACE))
  321.               {
  322.                doing=DOING_FNDFACE;
  323.                SayV(FndFace);
  324.            face=AllocPooled(wabl->WABL_Pool,sizeof(struct DXFFace));
  325.                face->dxf_pa=(pa=AllocPooled(wabl->WABL_Pool,sizeof(struct DXFPoint)));
  326.                face->dxf_pb=(pb=AllocPooled(wabl->WABL_Pool,sizeof(struct DXFPoint)));
  327.                face->dxf_pc=(pc=AllocPooled(wabl->WABL_Pool,sizeof(struct DXFPoint)));
  328.                face->dxf_pd=(pd=AllocPooled(wabl->WABL_Pool,sizeof(struct DXFPoint)));
  329.                if (arg[ARG_NOCOLORS]!=0)
  330.                 {
  331.          struct DXFObj *obj;
  332.          obj=HaveObjFromColor(&dxf,1);
  333.          AddTail(&obj->dxo_faces,&face->dxf_node);
  334.          AddTail(&obj->dxo_points,&pa->dxp_node);
  335.          AddTail(&obj->dxo_points,&pb->dxp_node);
  336.          AddTail(&obj->dxo_points,&pc->dxp_node);
  337.          AddTail(&obj->dxo_points,&pd->dxp_node);
  338.             }
  339.           }
  340.             }
  341.        else
  342.         {
  343.          if (doing==DOING_FNDFACE)
  344.           {ULONG num;
  345.            if ((StrToLong(use,&num))>0) 
  346.             {
  347.              switch (num)
  348.               {
  349.                case 10: {doing=DOING_VALUEXA;SayV(FndXA);break;}
  350.                case 11: {doing=DOING_VALUEXB;SayV(FndXB);break;}
  351.                case 12: {doing=DOING_VALUEXC;SayV(FndXC);break;}
  352.                case 13: {doing=DOING_VALUEXD;SayV(FndXD);break;}
  353.                case 20: {doing=DOING_VALUEYA;SayV(FndYA);break;}
  354.                case 21: {doing=DOING_VALUEYB;SayV(FndYB);break;}
  355.                case 22: {doing=DOING_VALUEYC;SayV(FndYC);break;}
  356.                case 23: {doing=DOING_VALUEYD;SayV(FndYD);break;}
  357.                case 30: {doing=DOING_VALUEZA;SayV(FndZA);break;}
  358.                case 31: {doing=DOING_VALUEZB;SayV(FndZB);break;}
  359.                case 32: {doing=DOING_VALUEZC;SayV(FndZC);break;}
  360.                case 33: {doing=DOING_VALUEZD;SayV(FndZD);break;}
  361.                case 62: {doing=DOING_VALUECOLOR;SayV(FndCL);break;}
  362.                case 0:  {doing=DOING_WAITFACE;break;}
  363.                default: {doing=DOING_VALUENULL;break;}
  364.               }
  365.             }
  366.               } // DOINGFOUNDFACE
  367.              else
  368.               {ULONG num;
  369.                if ((StrToLong(use,&num))>0)
  370.                 {
  371.          if ((doing!=DOING_VALUENULL) & (arg[ARG_VERBOSE]!=0)) RawDoFmt(NumFmt,&num,&RawDoFmtOut,outfh);
  372.          switch (doing)
  373.           {
  374.            case DOING_VALUEXA: {pa->dxp_x=num;break;}
  375.            case DOING_VALUEYA: {pa->dxp_y=num;break;}
  376.            case DOING_VALUEZA: {pa->dxp_z=num;break;}
  377.            case DOING_VALUEXB: {pb->dxp_x=num;break;}
  378.            case DOING_VALUEYB: {pb->dxp_y=num;break;}
  379.            case DOING_VALUEZB: {pb->dxp_z=num;break;}
  380.            case DOING_VALUEXC: {pc->dxp_x=num;break;}
  381.            case DOING_VALUEYC: {pc->dxp_y=num;break;}
  382.            case DOING_VALUEZC: {pc->dxp_z=num;break;}
  383.            case DOING_VALUEXD: {pd->dxp_x=num;break;}
  384.            case DOING_VALUEYD: {pd->dxp_y=num;break;}
  385.            case DOING_VALUEZD: {pd->dxp_z=num;break;}
  386.            case DOING_VALUECOLOR: 
  387.             {
  388.              if (arg[ARG_NOCOLORS]==0) 
  389.               {
  390.                struct DXFObj *obj;
  391.                obj=HaveObjFromColor(&dxf,num);
  392.                AddTail(&obj->dxo_faces,&face->dxf_node);
  393.                AddTail(&obj->dxo_points,&pa->dxp_node);
  394.                AddTail(&obj->dxo_points,&pb->dxp_node);
  395.                AddTail(&obj->dxo_points,&pc->dxp_node);
  396.                AddTail(&obj->dxo_points,&pd->dxp_node);
  397.               }
  398.             }
  399.           }
  400.                 }
  401.                doing=DOING_FNDFACE;
  402.               } // VALUEHAVE
  403.         }
  404.           } // INPUT PART
  405.           Close(fh);
  406.           
  407.           {
  408.            struct WABLObject *alien,*sector,*shell,*wire,*nebula,*point,*face,*edge;
  409.            ULONG idsector=NULL,idshell=NULL,idwire=NULL,idnebula=NULL,
  410.                 idpoint=NULL,idedge=NULL,idface=NULL;
  411.            Say(Converting);
  412.            if (alien=HaveWABLObject(wabl,&AlienType,&AlienName,wabl))
  413.             {
  414.              struct DXFObj *cob,*nob;
  415.              cob=dxf.dxg_objs.mlh_Head;
  416.              
  417.              while (nob=cob->dxo_node.mln_Succ)
  418.               {
  419.                idsector++;LongToHexStr(idsector,&SectorName[3],3);
  420.                if (sector=HaveWABLObject(wabl,&SectorType,&SectorName,alien))
  421.                 {                                          
  422.          idnebula++;LongToHexStr(idnebula,&NebulaName[3],3);
  423.          if (nebula=HaveWABLObject(wabl,&NebulaType,&NebulaName,sector))
  424.           {
  425.            struct DXFPoint *cpo,*npo;
  426.            ULONG fakeida=NULL,fakeidb=NULL;        // to see remaps
  427.            Say(DoublePnts);
  428.            cpo=cob->dxo_points.mlh_Head;
  429.            fakeida++;fakeidb=fakeida;
  430.            while (npo=cpo->dxp_node.mln_Succ)
  431.             {
  432.              struct DXFPoint *icpo,*inpo;
  433.              fakeidb++;
  434.                cpo->dxp_remap=NULL;
  435.              icpo=npo;
  436.              while (inpo=icpo->dxp_node.mln_Succ)
  437.               {
  438.                if ((cpo->dxp_x==icpo->dxp_x) & (cpo->dxp_y==icpo->dxp_y) & (cpo->dxp_z==icpo->dxp_z))
  439.                 {
  440.                  Remove(&cpo->dxp_node);
  441.                  cpo->dxp_remap=icpo;
  442.                  LongToHexStr(fakeida,&RemapPoint[RMP_IT],4);
  443.                  LongToHexStr(fakeidb,&RemapPoint[RMP_INTO],4);
  444.                  SayV(RemapPoint);
  445.                 }
  446.                icpo=inpo;
  447.               } // INTERNALCYCLE
  448.              cpo=npo;
  449.             } // POINTDOUBLECHECK
  450.  
  451.            Say(CreatePnts);
  452.            cpo=cob->dxo_points.mlh_Head;
  453.            while (npo=cpo->dxp_node.mln_Succ)
  454.             {
  455.              idpoint++;cpo->dxp_id=idpoint;
  456.             
  457. #define    NamePoint(pnt) LongToHexStr(pnt->dxp_id,&PointName[3],4); 
  458.             
  459.              NamePoint(cpo);
  460.              if (point=HaveWABLObject(wabl,&PointType,&PointName,nebula))
  461.               {
  462.                Val(cpo->dxp_x,use);
  463.                  SetWABLAttr(wabl,&PointX,use,point);
  464.                Val(cpo->dxp_y,use);
  465.                  SetWABLAttr(wabl,&PointY,use,point);
  466.                Val(cpo->dxp_z,use);
  467.                  SetWABLAttr(wabl,&PointZ,use,point);
  468.                 } // POINT
  469.              cpo=npo;
  470.             } 
  471.             
  472.           } // NEBULA
  473.  
  474.          idshell++;LongToHexStr(idshell,&ShellName[3],3);
  475.          if (shell=HaveWABLObject(wabl,&ShellType,&ShellName,sector))
  476.           {
  477.            struct DXFFace *cfa,*nfa;
  478.            struct INTERFace *cif,*nif;
  479.            Say(DoubleFaces);
  480.            cfa=cob->dxo_faces.mlh_Head;
  481.            while (nfa=cfa->dxf_node.mln_Succ)
  482.             {
  483.                cfa->dxf_pa=HaveRemapPoint(cfa->dxf_pa);
  484.                cfa->dxf_pb=HaveRemapPoint(cfa->dxf_pb);
  485.                cfa->dxf_pc=HaveRemapPoint(cfa->dxf_pc);
  486.                cfa->dxf_pd=HaveRemapPoint(cfa->dxf_pd);
  487.  
  488.              LongToHexStr(cfa->dxf_pa->dxp_id,&OriginalFace[ORF_PA],4);
  489.              LongToHexStr(cfa->dxf_pb->dxp_id,&OriginalFace[ORF_PB],4);
  490.              LongToHexStr(cfa->dxf_pc->dxp_id,&OriginalFace[ORF_PC],4);
  491.              LongToHexStr(cfa->dxf_pd->dxp_id,&OriginalFace[ORF_PD],4);
  492.              SayV(OriginalFace);             
  493.  
  494.              if (cif=AddINTERFace(cob,cfa->dxf_pa,cfa->dxf_pb,cfa->dxf_pc)) {idface++;cif->if_id=idface;}
  495.              if (cif=AddINTERFace(cob,cfa->dxf_pa,cfa->dxf_pc,cfa->dxf_pd)) {idface++;cif->if_id=idface;}
  496.  
  497.              cfa=nfa;
  498.             } // FACEINTECONV
  499.            cif=cob->dxo_ifaces.mlh_Head;
  500.            Say(CreateFaces);
  501.            while (nif=cif->if_node.mln_Succ)
  502.             {
  503.              struct INTEREdge *edga,*edgb,*edgc;
  504.              if ((edga=AddINTEREdge(cob,cif->if_pa,cif->if_pb))->ie_id==0) {idedge++;edga->ie_id=idedge;}
  505.              if ((edgb=AddINTEREdge(cob,cif->if_pa,cif->if_pb))->ie_id==0) {idedge++;edgb->ie_id=idedge;}
  506.              if ((edgc=AddINTEREdge(cob,cif->if_pa,cif->if_pb))->ie_id==0) {idedge++;edgc->ie_id=idedge;}
  507.  
  508. #define    NameFace(fac) LongToHexStr(fac->if_id,&FaceName[3],4); 
  509. #define    NameEdge(edg) LongToHexStr(edg->ie_id,&EdgeName[3],4); 
  510.              
  511.              NameFace(cif);
  512.              if (face=HaveWABLObject(wabl,&FaceType,&FaceName,shell))
  513.               {
  514.                NamePoint(cif->if_pa);
  515.                  SetWABLAttr(wabl,&FacePA,&PointName,face);
  516.                NamePoint(cif->if_pb);
  517.                  SetWABLAttr(wabl,&FacePB,&PointName,face);
  518.                NamePoint(cif->if_pc);
  519.                  SetWABLAttr(wabl,&FacePC,&PointName,face);              
  520.                NameEdge(edga);
  521.                  SetWABLAttr(wabl,&FaceEA,&EdgeName,face);
  522.                NameEdge(edgb);
  523.                  SetWABLAttr(wabl,&FaceEB,&EdgeName,face);
  524.                NameEdge(edgc);
  525.                  SetWABLAttr(wabl,&FaceEC,&EdgeName,face);               
  526.               } // SAVEFACE
  527.              cif=nif;
  528.             } // SAVEFACES
  529.            
  530.           } // SHELL
  531.           
  532.                  idwire++;LongToHexStr(idwire,&WireName[3],3);
  533.          if (wire=HaveWABLObject(wabl,&WireType,&WireName,sector))
  534.           {
  535.            struct INTEREdge *cie,*nie;
  536.            Say(AddEdges);
  537.            cie=cob->dxo_iedges.mlh_Head;
  538.            while (nie=cie->ie_node.mln_Succ)
  539.             {
  540.              NameEdge(cie);
  541.              if (edge=HaveWABLObject(wabl,&EdgeType,&EdgeName,wire))
  542.               {
  543.                NamePoint(cie->ie_pa);
  544.                  SetWABLAttr(wabl,&EdgePA,&PointName,edge);
  545.                NamePoint(cie->ie_pb);
  546.                  SetWABLAttr(wabl,&EdgePB,&PointName,edge);
  547.               } // SAVEEDGE
  548.              cie=nie;
  549.             }
  550.           } // WIRE
  551.                 } // SECTOR
  552.                cob=nob;
  553.               } // SECTORS 
  554.             } // ALIEN 
  555.       } // ELABORATION PART        
  556.  
  557.       {
  558.        if (fh=Open(arg[ARG_WABLOUTPUT],MODE_NEWFILE))
  559.         {
  560.          struct Hook puthook;
  561.              struct TagItem savetags[3]={{WABL_FileHandle,fh},{WABL_PutCharHook,&puthook},{0,0}};
  562.          Say(Saving);
  563.              puthook.h_Entry=&WriteHook;
  564.              SaveWABL(wabl,&savetags[0]);             
  565.              Close(fh);
  566.              Say(Bye);
  567.         } // OUTHAD 
  568.       } // SAVEPART
  569.         } // USE
  570.        FreeWABL(wabl);
  571.       } // WABL
  572.     } // DXFOPEN
  573.   } // READARGS
  574. }
  575.  
  576.